package com.study.mybatis;


import com.study.mybatis.mapper.UserMapper;
import com.study.mybatis.service.UserService;
import com.study.mybatis.service.ZhouyuFactoryBean;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @program: spring
 * @author: jzhou
 * @date: 2022-04-21 21:43
 * @version: 1.0
 * @description: 测试
 **/
public class Test {
	public static void main(String[] args) {
		AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
		applicationContext.register(AppConfig.class);

		AbstractBeanDefinition beanDefinition = BeanDefinitionBuilder.genericBeanDefinition().getBeanDefinition();
		beanDefinition.setBeanClass(ZhouyuFactoryBean.class);
		beanDefinition.getConstructorArgumentValues().addGenericArgumentValue(UserMapper.class);

		applicationContext.registerBeanDefinition("userMapper",beanDefinition);

		applicationContext.refresh();

		UserService userService = (UserService) applicationContext.getBean("userService");
		userService.test();
//		System.out.println(applicationContext.getBean("zhouyuFactoryBean"));
//		System.out.println(applicationContext.getBean("&zhouyuFactoryBean"));

	}
}
